import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.core.io.ClassPathResource;

import java.util.Date;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: ttq
 * Date: 13-7-30
 * Time: 上午9:33
 * To change this template use File | Settings | File Templates.
 */
public class SpringTest {
    public static void main(String[] args) throws Exception {
        XmlBeanFactory factory = new XmlBeanFactory(new ClassPathResource("spring-config.xml"));
        ICatDao catDao = (ICatDao) factory.getBean("catDao");
        Cat cat = new Cat();
        cat.setName("Hello Kitty");
        cat.setCreateDate(new Date());
        catDao.createCat(cat);

        List<Cat> catList = catDao.listCats();
        for (Cat cat1 : catList) {
            System.out.println("Name:" + cat1.getName());
        }
//        TransactionRun transactionRun = (TransactionRun) factory.getBean("transactionRun");
//        transactionRun.run();
//        IAopService hello = (IAopService) factory.getBean("aopService");
//        hello.withAop();
////        hello.withoutAop();
//        factory.destroySingletons();
//        IPersonDao personDao = (IPersonDao) factory.getBean("personDao");
//        Person person = new Person();
//        person.setName("Helloween");
//        person.setAge(30);
//        person.setSex("man");
//        person.setBirthday(new Date());
//        personDao.addPerson(person);
//        System.out.println("Count: " + personDao.getPersonsCount());
//        System.out.println(personDao.getPersonName(1));
//        List<Person> personList = personDao.listPersons();
//        for (Person p : personList) {
//            System.out.println("name:" + p.getName());
//        }
    }
}
